﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>版本列表</title>
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Comm/fonts/font-icons.min.css" rel="Stylesheet" />
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script language="JavaScript" src="../../Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/layui/layui/layui.js" type="text/javascript"></script>
    <script src="../../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
    <style type="text/css">
        .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
            top: 0px !important;
        }
    </style>
    <script type="text/javascript">
        var dbvars = null;
        $(function () {

            var frmID = GetQueryString("FrmID");
            var refpk = GetQueryString("RefPKVal") || GetQueryString("EnPKValue");
            dbvars = new Entities("BP.Sys.EnVers");
            dbvars.Retrieve("FrmID", frmID, "EnPKValue", refpk, "EnVer");
            layui.table.render({
                elem: '#tableID',
                cellMinWidth: 80,
                cols: [[
                    { type: 'checkbox', align: 'center' }
                    , { field: 'MyPK', title: 'MyPK', hide: true, align: 'center' }
                    , {
                        field: 'EnVer', title: '版本号', align: 'center',
                        templet: function (row) {
                            return "Ver" + row["EnVer"] + ".0";
                        }
                    }

                    , { field: 'RDT', title: '修改日期', }
                    , { field: 'RecName', title: '修改人', }
                    , {
                        field: '_operate', title: '操作',
                        templet: function (row) {
                            return "<a class='layui-btn  layui-btn-primary layui-border-blue  layui-btn-xs' lay-event='RollBack'><i class='icon-reload'></i>还原到当前版本</a>";
                        }
                    }

                ]],
                data: dbvars.TurnToArry(),
                text: {
                    none: '暂无数据版本,不需要版本比对'
                }
            });
            layui.table.on('tool(tableID)', function (obj) {
                var data = obj.data;
                if (obj.event === 'RollBack') {
                    var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_DataVer");
                    handler.AddUrlData();
                    handler.AddPara("MyPK", data.MyPK);
                    var data = handler.DoMethodReturnString("DataVer_RollBack");
                    if (data.indexOf("err@") != -1) {
                        layer.alert(data);
                        return;
                    }
                    layer.alert('数据还原成功');
                }
            });
            $("#Btn_Compare").on("click", function () {
                //选择的版本是不是两个，
                var checkedItems = layui.table.checkStatus('tableID');
                if (checkedItems.data.length != 2) {
                    layer.alert("只能选择两个数据版本进行比对");
                    return;
                }
                var ver1 = checkedItems.data[0].EnVer;
                var ver2 = checkedItems.data[1].EnVer;
                var url = "./DataVer.htm?FrmID=" + frmID + "&RefPK=" + refpk + "&MainVer=" + ver1 + "&CompareVer=" + ver2;
                OpenFullLayuiDialog(url, "版本比对");
            });
            if (dbvars < 2) {
                if (dbvars.length == 1)
                    $("#shuoming").html("当前实体只存在一个数据版本,不需要比对");
                $("#Btn_Compare").attr("disabled", "true");
            }

        });

    </script>
</head>
<body>
    <div class="layui-container" style="margin-top:20px">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="Btn_Compare">版本比对</button>
        <table class="layui-table" id="tableID" lay-filter="tableID"></table>
        <label class="layui-menu-body-title" id="shuoming"></label>
    </div>
</body>
</html>
